#include<fstream>
#include<string>
#include"FunctionPtr.h"
#include"Actions.h"

using namespace std;


int main() {
	ofstream out("output.txt");
        ifstream in("input.txt");
        int file_size = 0;
        int i = 0;
        in >> file_size;
        while (i < file_size) {
            string function;
            string operation;
            double begin = 0;
            double end = 0;
            double step = 0;
            in >> function >> operation >> begin >> end >> step;
            FunctionPtr func(function);
            if(operation == "sol") {
                double answer = 0;
                if( solve(func, begin, end, step, answer) ) {
                    out << answer << endl;
                } else {
                    out << "can't solve" << endl;
                }
            }
            if(operation == "int") {
                out << integrate(func, begin, end, step) << endl;
            }
            ++i;
        }
        in.close();
        out.close();
	return 0;
}
